home *** CD-ROM | disk | FTP | other *** search
/ Knitting Made Easy / Knitting.iso / App / Patterns.dxr / behaviors_182_Scroll Indicator Behavior.ls < prev    next >
Encoding:
Text File  |  2002-04-18  |  1.4 KB  |  49 lines

  1. property pIndicatorLowerLimit, pIndicatorRange, pClickedStatus, pCurrentSprite
  2.  
  3. on beginSprite me
  4.   pCurrentSprite = me.spriteNum
  5.   spacing = 3
  6.   offset = (the height of sprite pCurrentSprite / 2) + spacing
  7.   trackSprite = pCurrentSprite - 1
  8.   trackSpriteTop = the top of sprite trackSprite
  9.   pIndicatorLowerLimit = trackSpriteTop + offset
  10.   trackSpriteBottom = the bottom of sprite trackSprite
  11.   indicatorUpperLimit = trackSpriteBottom - offset
  12.   pIndicatorRange = indicatorUpperLimit - pIndicatorLowerLimit
  13.   set the locV of sprite pCurrentSprite to pIndicatorLowerLimit
  14. end
  15.  
  16. on positionIndicator me, textRatio
  17.   currentPosition = pIndicatorRange * textRatio
  18.   indicatorPosition = currentPosition + pIndicatorLowerLimit
  19.   set the locV of sprite pCurrentSprite to indicatorPosition
  20. end
  21.  
  22. on mouseDown me
  23. end
  24.  
  25. on exitFrame me
  26.   if the mouseDown and (the clickOn = pCurrentSprite) then
  27.     scrollTextWithIndicator(me, the mouseV)
  28.   end if
  29. end
  30.  
  31. on scrollTextWithIndicator me, mouseVertical
  32.   nextPosition = mouseVertical
  33.   if nextPosition < pIndicatorLowerLimit then
  34.     nextPosition = pIndicatorLowerLimit
  35.   else
  36.     upperLimit = pIndicatorLowerLimit + pIndicatorRange
  37.     if nextPosition > upperLimit then
  38.       nextPosition = upperLimit
  39.     end if
  40.   end if
  41.   ratioPosition = float(nextPosition - pIndicatorLowerLimit)
  42.   ratio = ratioPosition / pIndicatorRange
  43.   sendAllSprites(#scrollText, ratio)
  44. end
  45.  
  46. on getIndicatorPosition me
  47.   return the locV of sprite pCurrentSprite
  48. end
  49.